<?php
/**
 * User: htt
 * Date: 2019-02-20
 * Time: 上午10:54
 */

namespace App\Models\User;

use App\Models\Admin\OrderBaleModel;
use App\Models\CompanysModel;
use App\Models\Model;

class UserOrdersModel extends Model
{
    protected $table = 'users_orders';

    
    
    const status_weifayuanliao=1;
    const status_jieshouyuanliao=2;
    const status_shengchanzhong=3;
    
    const status_kehugendan=4;    
    const status_querengendan=5;    
    const status_fabaofahuo=6;
    
    const status_daohuoqianshou=7;    
    const status_pingjia=8;
    const status_wancheng=9;


        public static function getStatus($status=null){
        $list=[
            self::status_weifayuanliao=>'未发原料',
            self::status_jieshouyuanliao=>'接收原料',
            self::status_shengchanzhong=>'生产中',
            
            self::status_kehugendan=>'客户跟单',
            self::status_querengendan=>'确认跟单',
            self::status_fabaofahuo=>'打包发货',
            
            self::status_daohuoqianshou=>'到货签收',
            self::status_pingjia=>'评价',
            self::status_wancheng=>'完成',

        ];
        if(!$status){
            return $list;
        }
        return isset($list[$status])?$list[$status]:'';
    }
    
    
    
    
    public function orderDetail()
    {
        return $this->hasOne(OrderBaleModel::class, 'id', 'bale');
    }
    
    public function orderCompany(){
        return $this->hasOne(CompanysModel::class, 'uid', 'cid');
    }

    public function orderFactory()
    {
        return $this->hasOne(CompanysModel::class, 'uid', 'fid');
    }
}
